import {computed, watch, ref, reactive} from 'vue';

import {useUserStore} from '@/store/modules/user';

const userStore = useUserStore();
/** 当前登录用户信息 */
const loginUser = computed(() => userStore.info ?? {});
let key = "maxLoginUserRoleKey";
let teacherRole = ["admin", "regularAdmin", "counsellor"];
let studentRole = ["student"];
let companyRole = ["student"];

export function selectLoginUserMaxRoleKey() {
  let loginUserMaxRoleKey = "";
  let loginUserMaxRoleNum = 99;
  if (loginUser.value.roles && loginUser.value.roles.length > 0) {
    for (let i = 0; i < loginUser.value.roles.length; i++) {
      if (loginUser.value.roles[i].roleSort < loginUserMaxRoleNum) {
        //代表当前的用户角色更靠前
        loginUserMaxRoleKey = loginUser.value.roles[i].roleKey;
        loginUserMaxRoleNum = loginUser.value.roles[i].roleSort;
      }
    }
  }
  return loginUserMaxRoleKey;
}

export function deleteLoginUserMaxRoleKey() {
  localStorage.setItem(key, "");//将当前用户最大的RoleKey存储起来
}







